﻿

using System;
using System.Collections;

namespace ConsoleAppStack
{
    class Program
    {
        static void Main(string[] args)
        {

            Stack stack = new Stack();
            stack.Push("一号犯人");
            stack.Push("二号犯人");
            stack.Push("三号犯人");
            stack.Push("四号犯人");
            stack.Push("五号犯人");

            Console.WriteLine("带犯人上刑场");
            foreach (var item in stack)
            {
                Console.WriteLine(item + "已就位");
            }

            Console.WriteLine("一共{0}人，准备斩立决",stack.Count);

            stack.Clear(); //清除元素
            Console.WriteLine("斩杀已完毕，剩余人数{0}",stack.Count);

           bool people= stack.Contains("五号犯人"); //判断元素是否在stack中
            if (people)
            {
                Console.WriteLine("五号犯人没死");
            }
            else
            {
                Console.WriteLine("该犯人已死");
            }

        }
    }
}
